<?php
class Mcreateproject extends CI_Model{

    public function __construct(){
        parent::__construct();        
        $this->load->database();
    }
		
   public function insert_project($data){

         if($this->db->insert("tbl_project",$data))
            return TRUE;
        else
            return FALSE;

    }  

 //--- Lay thong tin 1 record qua id
    function getAllProject(){
        $this->db->select("id,name_project,video_project");
        $this->db->order_by("id desc");
        $query=$this->db->get("tbl_project");


        if($query)
            //tra ve tat ca cac ban ghi    
            return $query->result_array();
        else
            return FALSE;
    }

function getProjectByID($id){
        $this->db->select("id,name_project,video_project");
        $this->db->where("id",$id);

        $query=$this->db->get("tbl_project");


        if($query)
            //tra ve 1 ban ghi
            return $query->row_array();
        else
            return FALSE;
    }



    public function update_ProjectByID($parram){    	
    	try{         
            $this->db->where('id', $parram["id"]);
    		$this->db->update("tbl_project", $parram);	
			return 0;
    	}catch(Exception $e){
 			throw new Exception();
 			return 1;
    	}
		
    }


}